using UnityEngine;

public class PlayerSkinSwitcher : MonoBehaviour
{
	public static int current;

	public PlayerRenderSkins[] skin = new PlayerRenderSkins[0];

	private SpriteRenderer[] renders = new SpriteRenderer[0];

	private AnimatorCurve[] hands = new AnimatorCurve[0];

	public static void SwitchSkin()
	{
		current++;
	}

	private void Start()
	{
		renders = base.gameObject.GetComponentsInChildren<SpriteRenderer>(includeInactive: true);
		hands = base.gameObject.GetComponentsInChildren<AnimatorCurve>(includeInactive: true);
		int num = 0;
		for (int i = 0; i < hands.Length; i++)
		{
			for (int j = 0; j < hands[i].clip.library.Length; j++)
			{
				for (num = 0; num < hands[i].clip.library[j].sprites.Length; num++)
				{
					hands[i].clip.library[j].sprites[num] = SwitchSprite(hands[i].clip.library[j].sprites[num], current);
				}
			}
		}
		for (int i = 0; i < renders.Length; i++)
		{
			renders[i].sprite = SwitchSprite(renders[i].sprite, current);
		}
	}

	public Sprite SwitchSprite(Sprite current, int selectedSkin)
	{
		int num = 0;
		for (int i = 0; i < skin.Length; i++)
		{
			for (num = 0; num < skin[i].sprites.Length; num++)
			{
				if (skin[i].sprites[num] == current)
				{
					return skin[i].sprites[selectedSkin % skin[i].sprites.Length];
				}
			}
		}
		return current;
	}
}
